PHP

How to define methods within the class in PHP | PHP program

How to define methods within the class in PHP | PHP program

How to define methods within the class in PHP | PHP program

We will define a class Sample class with two methods within the class.

<?php

class Sample
{

    function Method1()
    {
        print ("Method1() called" . '<br>');
    }
    function Method2()
    {
        print ("Method2() called" . '<br>');
    }
}

$S = new Sample();

$S->Method1();
$S->Method2();
?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community